//
//  CopyrightNoticeViewController.m
//  网络FM
//
//  Created by dlios on 15/5/28.
//  Copyright (c) 2015年 dengzhicheng.com. All rights reserved.
//

#import "CopyrightNoticeViewController.h"
#import "SettingViewController.h"
#define HEIGHT [[UIScreen mainScreen] bounds].size.height

@interface CopyrightNoticeViewController ()

@property (nonatomic, retain) UILabel *label;

@end

@implementation CopyrightNoticeViewController
- (void)dealloc
{
    [_label release];
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self createView];
        
    }
    return self;
}

-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
    
    
    //如果往右滑
    
    if(recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
}

- (void)createView
{
    NSString *str = @"       本应用所发表的所有内容，包括文字、图片、音频、视频、以及页面版式设计等均在网上搜集。\n       访问者可将本网站提供的内容或服务用于个人学习、研究或欣赏，以及其他非商业性或非盈利性用途，但同时应遵守著作权法及其他相关法律的规定，不得侵犯本应用及相关权利人的合法权利。除此以外，将本应用任何内容或服务用于其他用途时，须征得本网站及相关权利人的书面许可，并支付报酬。\n       本应用内容原作者如不愿意在本应用刊登内容，请及时通知英语，予以删除。\n\n\n    地址：大连\n    电话：18342032435\n    邮箱：420385517@qq.com";
    
    if (HEIGHT == 480) {
        [self createLabel:str size:14];
    } else if (HEIGHT == 568)
    {
        [self createLabel:str size:15];
    } else if (HEIGHT == 667)
    {
        [self createLabel:str size:16];
    } else {
        [self createLabel:str size:18];
    }
   
    
    
    UILabel *copyright = [[UILabel alloc]initWithFrame:CGRectMake(0 ,10 ,self.view.frame.size.width,64)];
    copyright.text = @"星空FM版权声明";
    copyright.textAlignment = NSTextAlignmentCenter;
    copyright.font = [UIFont boldSystemFontOfSize:20];
    
    [self.view addSubview:copyright];
    [copyright release];
    
    
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 1)];
    [view setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:view];
    [view release];
    



}


- (void)viewDidLoad {
    [super viewDidLoad];
    UISwipeGestureRecognizer * recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    
    [self.view addGestureRecognizer:recognizer];
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
}


- (void)createLabel:(NSString *)str size:(NSInteger)size
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:size]};
    CGRect rect = [str boundingRectWithSize:CGSizeMake(self.view.frame.size.width - 60, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(30, 64 + 30, self.view.frame.size.width - 60, rect.size.height)];
    self.label.text = str;
    self.label.numberOfLines = 0;
    self.label.textColor = [UIColor blackColor];
    [self.label setFont:[UIFont systemFontOfSize:size]];
    [self.label setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:_label];
    [_label release];
}




@end
